const webpack = require('webpack')
const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    mode:'production',
    entry:'./src/main.js',
    output:{
        filename:'bandel.js',
        path:path.join(__dirname,'dist')
    },
    module:{
        rules:[
            {
                test:/.vue$/,
                use:[
                    'vue-loader'
                ]
            },
            {
                test:/.vue$/,
                use:[
                    'eslint-loader'
                ],
                enforce:'pre'
            },
            {
                test:/.png$/,
                use:{
                    loader:'url-loader',
                    options:{
                        limit:15 *1024
                    }
                } 
            },   
            {
                test:/.css$/,
                use:[
                    'style-loader',
                    'css-loader'
                ]
            },
            {
                test:/.html$/,
                use:{
                    loader:'html-loader',
                    options:{
                        attributes:{
                            list:[
                                {
                                    tag:'img',
                                    attribute:'src',
                                    type:'src'
                                },
                                {
                                    tag:'link',
                                    attribute:'href',
                                    type:'src'
                                }
                            ]
                        }
                       
                    }
                }
            },{
                test:/.less$/,
                use:[
                    'style-loader',
                    'css-loader',
                    'less-loader'
                ]
            }
             
        ]
        
    },
    plugins:[
        new VueLoaderPlugin(),
        new CleanWebpackPlugin(),
        new HtmlWebpackPlugin({
                title:'vue-webpack',
            
            template:'./public/index.html'
        }),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.DefinePlugin({
            BASE_URL:'./public/'
        })
    ],
    devServer:{
        contentBase:'./public',
        hot:true
    },
    devtool:'eval'
} 